﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using sexhealth.console.service.post.vo;
using System.Collections;
using sexhealth.console.service.post;
using System.Text;
public partial class usercontrol_MediaList : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["chid"] != null)
            {
                int chid = int.Parse(Request["chid"]);
                PostService postService = new PostService();
                ChannelVO ch = postService.DaoGetVOById<ChannelVO>(chid);
                StringBuilder sb = new StringBuilder();
                if (ch.ParentId == 0)
                {
                    IList<ChannelVO> childChannelList = postService.GetChannelList(chid);
                    if (childChannelList.Count > 0)
                    {
                        IList<PostVO> postList = postService.GetPostList(childChannelList[0].ChannelNo);
                        if (childChannelList[0].ChannelNo == 14)
                        {
                            foreach (PostVO post in postList)
                            {

                                sb.Append("<tr>");
                                sb.Append("<td class='text06'><strong>" + post.Title + "</strong></td>");
                                sb.Append("</tr>");
                                sb.Append("<tr>");
                                sb.Append("<td class='text04'>" + post.HtmlContent + "</td>");
                                sb.Append("</tr>");
                                sb.Append("<tr>");
                                sb.Append("<td><embed src='upload/media/" + post.FileLink + "' width='439' height='329'></td>");
                                sb.Append("</tr>");

                                //sb.Append("<tr>");
                                //sb.Append("<td width='73%'>");
                                //sb.Append("<embed src='upload/media/" + post.FileLink + "' width='439' height='329'>");
                                //sb.Append("</td>");
                                //sb.Append("<td width='27%' class='text06'><strong>" + post.Title + "</strong></td>");
                                //sb.Append("</tr>");


                            }
                        }
                        else if (childChannelList[0].ChannelNo == 15)
                        {
                            foreach (PostVO post in postList)
                            {
                                sb.Append("<tr>");
                                sb.Append("<td><div class='text05'>" + post.Title + "</div></td>");
                                sb.Append(" </tr>");
                                sb.Append("<tr>");
                                sb.Append(" <td  class='text04'>"+post.HtmlContent+"</td>");
                                sb.Append(" </tr>");
                                sb.Append("<tr>");
                                sb.Append("  <td height='31' valign='top'><audio src='upload/media/" + post.FileLink + "' controls></td>");
                                sb.Append(" </tr>");

                                //sb.Append("<tr><td>");
                                //sb.Append("<table border='0' cellpadding='0' cellspacing='4' class='video-box'>");
                                //sb.Append("<tr><td><div class='text05'>" + post.Title + "</div></td></tr>");
                                //sb.Append("<tr><td height='36'> <audio src='upload/media/" + post.FileLink + "' controls>  </td></tr>");
                                //sb.Append("</table>");
                                //sb.Append("</td></tr>");
                            }

                        }
                        ltlPostList.Text = sb.ToString();
                        ltlSubChannelName.Text = childChannelList[0].Name;
                        ltlLocationName.Text = childChannelList[0].Name;
                    }
                }
                else
                {
                    IList<PostVO> postList = postService.GetPostList(chid);
                    if (chid == 14)
                    {
                        foreach (PostVO post in postList)
                        {
                            sb.Append("<tr>");
                            sb.Append("<td class='text06'><strong>" + post.Title + "</strong></td>");
                            sb.Append("</tr>");
                            sb.Append("<tr>");
                            sb.Append("<td class='text04'>" + post.HtmlContent + "</td>");
                            sb.Append("</tr>");
                            sb.Append("<tr>");
                            sb.Append("<td><embed src='upload/media/" + post.FileLink + "' width='439' height='329'></td>");
                            sb.Append("</tr>");
                        }
                    }
                    else if (chid == 15)
                    {
                        foreach (PostVO post in postList)
                        {
                            sb.Append("<tr><td>");
                            sb.Append("<table border='0' cellpadding='0' cellspacing='4' class='video-box'>");
                            sb.Append("<tr><td><div class='text05'>" + post.Title + "</div></td></tr>");
                            sb.Append("<tr><td height='36'> <audio src='upload/media/" + post.FileLink + "' controls>  </td></tr>");
                            sb.Append("</table>");
                            sb.Append("</td></tr>");
                        }

                    }
                    ltlPostList.Text = sb.ToString();
                    ltlSubChannelName.Text = ch.Name;
                    ltlLocationName.Text = ch.Name;
                }
            }
        }
    }
}
